package com.srd.phone.bean;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class CarouselInfo {

    public int id;
    public String uptime;
    public int position;
    public String direction;
    public int isenable;
    public String imgsrc;
    public String conte;
    public String operator;
    public String src;
    public int sort;

    public static List<CarouselInfo> parser(String json) {
        List<CarouselInfo> list = new ArrayList<>();
        try {
            JSONArray jsonArray = new JSONArray(json);
            for (int i = 0; i < jsonArray.length(); i++) {
                CarouselInfo info = new CarouselInfo();
                JSONObject jsonObject = jsonArray.optJSONObject(i);
                info.id = jsonObject.optInt("id");
                info.uptime = jsonObject.optString("uptime");
                info.direction = jsonObject.optString("direction");
                info.imgsrc = jsonObject.optString("imgsrc");
                info.conte = jsonObject.optString("conte");
                info.operator = jsonObject.optString("operator");
                info.src = jsonObject.optString("src");
                info.position = jsonObject.optInt("position");
                info.isenable = jsonObject.optInt("isenable");
                info.sort = jsonObject.optInt("sort");
                list.add(info);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

}
